package crack.plane_strain_compression_test;

import crack.AbstractPlaneStrainCompressionTestUsingSDAElement;
import fem2.AbstractStructuralCrackDemo;
import fem2.Element;
import fem2.MaterialModel;
import fem2.Mesh;
import fem2.MeshGenerator;
import fem2.MeshPart;
import fem2.Model;
import fem2.element.crack_sda.SKONConstantJumpCSTElement;
import fem2.material.cohesive_law.CohesiveLaw;
import fem2.material.cohesive_law.Mode1JirasekExponentialCohesiveLaw;
import fem2.pre_and_post.PatchMeshGenerator;
import fem2.pre_and_post.PatchMeshGenerator.PatchType;

public class PlaneStrainCompressionTestStructuredMesh1UsingSKONConstantCSTElementAndJirasekExponentialCohesiveLaw
		extends AbstractPlaneStrainCompressionTestUsingSDAElement {

	public PlaneStrainCompressionTestStructuredMesh1UsingSKONConstantCSTElementAndJirasekExponentialCohesiveLaw() {
		meshFileName = "structured-mesh1";
	}

	@Override
	public Mesh createMesh() {
		MeshGenerator mg = new PatchMeshGenerator(5, 15, 0.0, 0.0, 10, 10);
		((PatchMeshGenerator) mg).setType(PatchType.TRIANGLE_LEFT_TO_RIGHT);
		return mg.getMesh(2);
	}

	@Override
	public CohesiveLaw createCohesiveLaw(Model m) {
		double ft = 63.41e-3;
		double H = -400e-3;
		double Gf = -ft * ft / (2 * H);
		double Dnn = 1.0;
		double Dmm = 1.0;
		return new Mode1JirasekExponentialCohesiveLaw(Gf, ft, Dnn, Dmm);
	}

	@Override
	public Element createElement(MeshPart mp, MaterialModel mm, CohesiveLaw cl) {
		return new SKONConstantJumpCSTElement(mp, mm, cl);
	}

	public static void main(String[] args) {
		AbstractStructuralCrackDemo demo = new PlaneStrainCompressionTestStructuredMesh1UsingSKONConstantCSTElementAndJirasekExponentialCohesiveLaw();

		double[] lambda = new double[] { 1};

		demo.run(lambda);
	}
}
